package Exercise;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

/**
 * @author 王艺锡
 * @version 1.0
 */
public class Exercise01 {
    public static void main(String[] args) throws Exception {
        Class<?> testClass = Class.forName("Exercise.privateTest");
        Object o = testClass.newInstance();
        Field name = testClass.getDeclaredField("name");
        name.setAccessible(true);
        name.set(o,"lihua");

        Method getName = testClass.getMethod("getName");
        System.out.println(getName.invoke(o));


    }
}

class privateTest{
    private String name = "hellokitty";

    public String getName() {
        return name;
    }


}
